import React, { useState, Fragment } from "react";
import CreateAndUpdate from "./components/CreateAndUpdate";
import MenuHeader from "./components/MenuHeader";
import TableList from "./components/TableList";

export default function MenuViews() {
  const [dialogTitle, setDialogTitle] = useState("新建");
  /* 弹框状态 */
  const [visible, setVisible] = React.useState(false);
  const changeModalState = data => {
    data ? setDialogTitle("修改") : setDialogTitle("新增");
    setVisible(!visible);
  };
  return (
    <Fragment>
      <MenuHeader visible={visible} changeModalState={changeModalState} />
      <TableList visible={visible} changeModalState={changeModalState} />
      <CreateAndUpdate visible={visible} changeModalState={changeModalState} dialogTitle={dialogTitle} />
    </Fragment>
  );
}
